package com.miracle.设计模式.创建型模式.简单工厂;

public class CalculatorFactory {
    public static Calculator createCalculator(String calculatorType){
        Calculator calculator = null;
        switch (calculatorType){
            case "add" :{
                calculator = new CalculatorAdd();
                break;
            }
            case "sub" :{
                calculator = new CalculatorSub();
                break;
            }
            case "mul" :{
                calculator = new CalculatorMul();
                break;
            }
            case "div" :{
                calculator = new CalculatorDiv();
                break;
            }
            default:{
                System.out.println("不存在的类型！");
            }
        }
        return calculator;
    }
}
